package com.runen.wnhz.runen.ui.activity.major;

import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.runen.wnhz.runen.R;
import com.runen.wnhz.runen.common.utils.StatusBarCompatUtils;
import com.runen.wnhz.runen.di.component.ApplicationComponent;
import com.runen.wnhz.runen.ui.activity.BaseActivity;
import com.runen.wnhz.runen.ui.fragment.major.IntroduceFragment;
import com.runen.wnhz.runen.widget.TitleBuilder;

import butterknife.BindView;

/**
 * 资料精选详情
 */
public class IntroductionActivity extends BaseActivity {
    @BindView(R.id.iv_introduction)
    ImageView ivIntroduction;
    @BindView(R.id.tv_consult)
    TextView tvConsult;
    @BindView(R.id.tv_buy_now)
    TextView tvBuy;

    private IntroduceFragment introduceFragment;
    //课程id  购买时候用到
    private String lid;

    @Override
    protected int getLayoutView() {
        return R.layout.activity_introduction;
    }

    @Override
    protected void onTitleClickListen(TitleBuilder.TitleButton clicked) {
        switch (clicked) {
            case LEFT:
                finish();
                break;
            case MIDDLE:
                break;
            case RIGHT:
                break;
            default:
                break;
        }
    }

    @Override
    protected void initStart() {
        StatusBarCompatUtils.getInstance().TranslucentStatusBar(this, R.color.title_green);
        String pic = getIntent().getStringExtra("pic");
        lid = getIntent().getStringExtra("lid");
        Glide.with(this).load(pic).into(ivIntroduction);
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        if (introduceFragment == null) {
            introduceFragment = IntroduceFragment.newInstance("", lid);
            transaction.add(R.id.ll_fragment_container, introduceFragment, IntroduceFragment.TAG);
        } else {
            transaction.show(introduceFragment);
        }
        transaction.commit();
    }

    @Override
    public void initToolBar(TitleBuilder mTitleBuilder) {
        mTitleBuilder.setMiddleTitleText("产品详情").setLeftDrawable(R.mipmap.icon_back)
                .seTitleBgRes(R.mipmap.bg_title)
                .setMiddleTitleTextColor(ContextCompat.getColor(this, R.color.text_white));
    }

    @Override
    public void setupAcitivtyComponent(ApplicationComponent appComponent) {

    }
}
